﻿<!DOCTYPE HTML>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/head :: commonHead('通知公告列表')">
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 通知公告管理 <span class="c-gray en">&gt;</span> 公告列表
<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i id="shuaxin" class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
	<form action="/admin/findNoticeByTitle">
		<input type="text" th:value="${titleTmp}" class="input-text" style="width:250px" placeholder="输入标题" id="" name="titleTmp" />
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜公告</button>
	</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
	<a href="javascript:;" onclick="notice_add('添加公告','/admin/notice-add','800','300')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加公告</a></span><span class="r">共有数据：<strong th:text="${noticeNum}"></strong> 条</span> </div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">公告列表</th>
			</tr>
			<tr class="text-c">
				<th width="45">序号</th>
				<th width="150">标题</th>
				<th width="150">内容</th>
				<th width="100">创建时间</th>
				<th width="100">创建人</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<tr class="text-c" th:each="notice,noticeStat : ${noticeList}">
				<td>
				<span th:text="${noticeStat.index+1}"></span>
				<input type="hidden" th:value="${notice.id}" class="inp"/>
				</td>
				<td th:text="${notice.title}"></td>
				<td th:text="${notice.content}"></td>
				<td th:text="${#calendars.format(notice.createDate,'yyyy-MM-dd')}"></td>
				<td th:text="${notice.admin_name}"></td>
				<td class="td-manage">
				<a style="text-decoration:none" class="ml-5" onClick="notice_edit(this,'公告编辑','/admin/notice-edit','800','300')" href="javascript:;" title="编辑">
				<i class="Hui-iconfont">&#xe6df;</i></a>
				<a title="删除" href="javascript:;" onclick="notice_del(this)"
				class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
		</tbody>
	</table>
</div>

<!-- 引入公共js -->
<span th:include="/common/on-load-js :: commonOnLoadJs"></span>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
function notice_add(title,url,w,h){
	layer_show(title,url,w,h);
}

function notice_edit(obj,title,url,w,h){
	var noticeId = $(obj).parents("tr").find(".inp").val();
	var urltmp = url+"?noticeId="+noticeId;
	layer_show(title,urltmp,w,h);
}

function notice_del(obj){
	layer.confirm('确认要删除吗？',function(index){
		var noticeId = $(obj).parents("tr").find(".inp").val();
		$.ajax({
			type: 'POST',
			url: '/admin/delNotice',
			data:{"noticeId":noticeId},
			dataType: 'json',
			success: function(data){
				if(data.res==0){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:1000});
				}else{
					layer.msg('操作失败!',{icon: 2,time:1000});
				}
			}
		});		
	});
}
</script>
</body>
</html>